package com.sunnypower.rushfitapp.Orderpart;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sunnypower.rushfitapp.R;
import com.sunnypower.rushfitapp.entity.VOrderCourseQuery;

import java.util.List;


public class OrderListAdapter extends BaseAdapter {

    private List<VOrderCourseQuery> mList;
    private Context mContext;
    private LayoutInflater mLayoutInflater;


    public OrderListAdapter(Context context, List<VOrderCourseQuery> list) {
        mContext = context;
        mList = list;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.order_list_item, null);
            viewHolder.order_cname = convertView.findViewById(R.id.order_cname);
            viewHolder.order_cname.setSelected(true);
            viewHolder.order_tname = convertView.findViewById(R.id.order_tname);
            viewHolder.order_tname.setSelected(true);
            viewHolder.order_time = convertView.findViewById(R.id.order_time);
            viewHolder.order_time.setSelected(true);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        VOrderCourseQuery bean = mList.get(position);
        viewHolder.order_cname.setText(bean.getCname());
        viewHolder.order_tname.setText(bean.getTname());
        viewHolder.order_time.setText(bean.getRCtime());

        return convertView;
    }

    private static class ViewHolder {
        public TextView order_cname;
        public TextView order_tname;
        public TextView order_time;
    }
}
